home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Util / B / Benchmark folder / Source Files / TBenchMarker.cp < prev    next >
Encoding:
Text File  |  1993-04-20  |  1.3 KB  |  51 lines  |  [TEXT/MPS ]

  1. // Copyright © 1992-1993 Emergent Behavior. All rights reserved.
  2.  
  3. //=================================================================
  4. #ifndef _TBENCHMARKER_
  5.     #include "TBenchMarker.h"
  6. #endif
  7.  
  8. //-----------------------------------------------------------------
  9. Time
  10. TBenchMarker::TestAdditionSpeed()
  11. {
  12.     unsigned long total = 0;
  13.     unsigned long    startTicks = TickCount();
  14.     for ( short counter = 1; counter < 200; ++counter ) {
  15.         total = 0;
  16.         for ( short number = 1; number < 20000; ++number )
  17.             total += number;
  18.     }
  19.     unsigned long    stopTicks = TickCount();
  20.     unsigned long     totalTicks    = stopTicks - startTicks;
  21.     return totalTicks;
  22. }
  23.  
  24. //-----------------------------------------------------------------
  25. long
  26. TBenchMarker::TestDivisionSpeed()
  27. {
  28.     extended total = 10.0e20;
  29.     unsigned long    startTicks = TickCount();
  30.     for ( float number = 15000; number > 1; --number )
  31.             total /= number;
  32.     unsigned long    stopTicks = TickCount();
  33.     unsigned long     totalTicks    = stopTicks - startTicks;
  34.     return totalTicks;
  35. }
  36.  
  37. //-----------------------------------------------------------------
  38. long
  39. TBenchMarker::TestRandomNumberSpeed()
  40. {
  41.     short random;
  42.     unsigned long    startTicks = TickCount();
  43.     for ( long number = 1; number < 75000; ++number ) {
  44.         random = Random();
  45.         random = Random();
  46.     }
  47.     unsigned long    stopTicks = TickCount();
  48.     unsigned long     totalTicks    = stopTicks - startTicks;
  49.     return totalTicks;
  50. }
  51.